package com.zhao.dota.controller;

import com.zhao.dota.model.Hero;
import com.zhao.dota.service.HeroService;
import com.zhao.dota.struct.Result;
import com.zhao.dota.vo.HeroVo;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
import java.util.stream.Collectors;

@RequestMapping("/dota2")
@RestController
public class Dota2Controller {

    @Resource
    private HeroService heroService;

    @RequestMapping("/heroes")
    public Result<List<HeroVo>> heroes() {
        List<Hero> list = heroService.list();
        List<HeroVo> collect = list.stream().map(HeroVo::new).collect(Collectors.toList());
        return Result.success(collect);
    }

}
